﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing.Text;

namespace CentralMonitoring
{
    class IconfontHelper
    {
        private static PrivateFontCollection pfcc;
        public static PrivateFontCollection PFCC
        {
            get { return pfcc ?? LoadFont(); }
            set { pfcc = value; }
        }

        private static bool jzfont = false;

        public static bool JzFont
        {
            get { return jzfont; }
            private set { jzfont = value; }
        }

        private static PrivateFontCollection LoadFont()
        {
            if (!JzFont)
            {
                pfcc = new PrivateFontCollection();
                //直接引用路径的写法
                pfcc.AddFontFile(Environment.CurrentDirectory + "/iconfont.ttf");                
                // 引用到资源库的写法，添加到资源里的字体库文件
                //byte[] fontData = Properties.Resources.iconfont;
                //unsafe
                //{
                //    fixed (byte* pFontData = fontData)
                //    {
                //        pfcc.AddMemoryFont((IntPtr)pFontData, fontData.Length);
                //    }

                //}
                JzFont = true;
            }
            return pfcc;
        }
    }
}
